<?php 
require_once("checklogin.php");
require_once("classQuanTriTin.php");
$qt = new quantritin;
//$tin= $qt->ListTin();
$idTL=-1; if (isset($_GET['idTL'])==true) $idTL = $_GET['idTL']; settype($idTL,"int");
$idLT=-1; if (isset($_GET['idLT'])==true) $idLT = $_GET['idLT']; settype($idLT,"int");
$lang=''; if (isset($_GET['lang'])==true) $lang = $_GET['lang'];
if (get_magic_quotes_gpc()==false) $lang = mysql_real_escape_string($lang);

	$pageSize = 6; //pageSize: số trang hiện ra trên trình duyệt: 1|2|3|4|5
	$pageNum = 1; //pageNum: số trang
	if (isset($_GET['pageNum'])==true) $pageNum = $_GET['pageNum'];
	settype($pageNum,"int");

//$tin = $qt->ListTin($idTL,$idLT,$lang);
$tin = $qt->ListTin($idTL,$idLT,$lang,$pageNum,$pageSize);
$totalRows = $qt->DemSoTinTrong1Loai($idTL,$idLT,$lang);

if (isset($_GET['sotin'])==true) $sotin=$_GET['sotin'];
settype($sotin,"int");
if ($sotin<=0) $sotin=1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>List tin xem danh sach</title>
<style>
#dstin th {
	color:#333333;
	background-image: url(../images/admin_label.jpg);
	background-repeat: repeat-x;
	height: 33px;
	width: auto;
	text-align: center;
}
#dstin {
	width: 90%;
	border-bottom-width: 2px;
	border-bottom-style: dotted;
	border-bottom-color: #61DD03;
	float: left;
}
.ngay {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}
.tin p{margin-top:5px;  margin-bottom:5px; text-align:justify; color:#660; }
.tin p:first-child{font-weight:bold; color:#C60;}
.tin p:first-child span{ font-style:italic; color:#060; font-size:14px}
p.tomtat:first-line { color:#06C}
p.tomtat:first-letter { font-size:22px; color:#C0C; font-weight:bold}
.action a{ color:#033; text-decoration:none}
.action a:hover{ color:#630; text-decoration:underline}
.hightlight {
	background-image: url(../images/admin_hover.png);
	background-repeat: repeat-y;
}
.them {	font-weight: bold;color: #FFFFFF; background-color: #FF9900;
		display: block; height: 22px; width: 50px; text-decoration: none;
		line-height: 22px; font-size: 14px; text-align: center; float:left;
}
.themtin {float: left; width: 50px;}
.hang {
	border-bottom-width: 3px;
	border-bottom-style: dotted;
	border-bottom-color: #FF0000;
}
<!--
	#pageList a {
	background-color:#333333;
	color:#FFFFFF;
	padding-left:5px;
	padding-right:5px;
	margin-left:5px;
	text-decoration:none;
	border: 1px dotted #999999;
	font-size: 12px;
	font-family: Arial, Helvetica, sans-serif;
	}
	#pageList a:hover{
		background-color:#FFA8A8;
		color:#000000;
		font-family: Arial, Helvetica, sans-serif;
	}
	#first a{
	background-image: url(icon_first.png);
	text-decoration: none;
	}
	#first a:hover{
	background-image: url(icon_first_hover.png);
	text-decoration: none;
	}
	#last a{
	background-image: url(icon_last.png);
	text-decoration: none;
	}
.col {
	width: 60px;
}
	#last a:hover{
	background-image: url(icon_last_hover.png);
	text-decoration: none;
	}
	#prev a{
	background-image: url(icon_prev.png);
	text-decoration: none;
	}
	#prev a:hover{
	background-image: url(icon_prev_hover.png);
	text-decoration: none;
	}
	#next a{
	background-image: url(icon_next.png);
	text-decoration: none;
	}
	#next a:hover{
	background-image: url(icon_next_hover.png);
	text-decoration: none;
	}
	.pageListSpan{
		padding-left:5px;
		padding-right:5px;
		margin-left:5px;
		background-color:#FF0000;
		font-weight: bold;
		color: #CCCCCC;
		border: 1px dotted #400000;
		font-family: Arial, Helvetica, sans-serif;
	}
	-->
    .hang_le {
	background-color: #72F722;
    }
    .hang_chan {
	background-color: #969696;
    }
</style>
<script type="text/javascript" src="../Scripts/jquery.js"></script>

<script>
$(document).ready(function(){

	$("img.anhien").click(function(){
		idTin=$(this).attr("value");
		obj = this;
		$.ajax({
		   url:'tintuc_anhien.php',
		   data: 'idTin='+ idTin,
		   cache: false,
		   success: function(data){ //Biến data khai báo tên khác cũng được, dùng để nhận dữ liệu đổ về
			obj.src = data;
			if (data=="AnHien_1.gif") obj.title="Nhắp vào để ẩn tin";
			else obj.title="Nhắp vào để hiện tin";
		  }
		});
	});

	$("img.noibat").click(function(){
		idTin = $(this).attr("value");
		obj = this;
		$.ajax({
		   url:'tintuc_noibat.php',
		   data: 'idTin='+ idTin,
		   cache: false,
		   success: function(data){
			obj.src = data;
			if (data=="NoiBat_1.png") 
				obj.title="Nhắp vào để chỉ định đây là tin bình thường";
			else  obj.title="Nhắp vào để chỉ định đây là tin nổi bật";
		   }
		});
	});


	$("#chonhet").click(function(){
		var status = this.checked;
		$("input[name='chon']").each(function(){this.checked=status;})
	});
	$("#hang").mouseover(function(){ $(this).addClass("hightlight");  });
	$("#hang").mouseout(function(){	 $(this).removeClass("hightlight"); });
	$("#xoahet").click(function(){
		var listid = "";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid + "," + this.value;
	   })
		listid = listid.substr(1);	 //alert(listid);
		if (listid=="") { alert("Bạn chưa chọn tin nào"); return;}
		hoi= confirm("Xoá hết hả");
		if (hoi==true) document.location = "tintuc_xoa.php?listid=" + listid;
	});
	$("#chinhhet").click(function(){
		var listid = "";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid + "," + this.value;
		});
		listid = listid.substr(1);	 //alert(listid);
		if (listid=="") { alert("Bạn chưa chọn tin nào"); return;}
		document.location = "tintuc_chinhhet.php?listid=" + listid;
	});



});
</script>	
<script>
$(document).ready(function(){
	$(".row:even").css("background-color","#BEFB99");
	$(".row:odd").css("background-color", "#E0E0E0");
	//$(".col:even").css("background-color","#009100");
	//$(".col:odd").css("background-color", "#6F6F6F");
	$(".col:even").addClass("hang_le");
	$(".col:odd").addClass("hang_chan");
});
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table id=dstin  border=0 cellpadding=4 cellspacing=0  width=87%  align=left>
<tr>
  <td colspan="2" align="left">
      <input type="button" name="xoahet" id="xoahet" value=" Xoá " />
      <input type="button" name="chinhhet" id="chinhhet" value="Chỉnh" />  </td>
  <td align="center"><p align="center" id="thanhphantrang"><?php echo $qt->pagesListLink($totalRows, $pageNum, $pageSize);?></p></td>
  <td align="right"> 
  
<select name="themtin" class="themtin" id="themtin">
    <option value="1">1</option> <option value="2">2</option>
    <option value="3">3</option> <option value="4">4</option>
    <option value="5">5</option>
</select>


<a href="main.php?p=tintuc_add" onClick="return true" class="them" id="them">Thêm</a><a href="main.php?p=tintuc_list&amp;lang=vi"><img src="NgonNgu_vi.png" width="35" height="35" /></a><a href="main.php?p=tintuc_list&amp;lang=en"><img src="NgonNgu_en.png" width="35" height="35" /></a> </td>
</tr>
<tr>
   <th width="127" align="left">
     <input type="checkbox" name="chonhet" id="chonhet" />
   </th>
   <th width="69"> idTin-Ngày </th>
   <th width="512"> Tiêu đề - Tóm tắt </th>
   <th> Action </th>
</tr>

<!—bắt đầu lặp -->
<?php 

	while ($row_tin = mysql_fetch_assoc($tin)) { ?>
<?php ob_start(); ?>

<tr class="row">
   <td class="col"><div align="center">
     <input type="checkbox" name="chon" id="chon" value="{idTin}" class="chon" />
   </div></td>
   <td align="center" class="ngay">
	 <p><span>idTin: {idTin} </span><br /> 
	      <span>{Ngay} </span> <br /> 
         <span>Xem: {SoLanXem}</span></p>	 </td>
   <td class="tin" valign=top>
     <p class="tieude">{TieuDe}   <span> ({TenTL} </span> / <span> {Ten}) </span> </p>
     <p class="tomtat">{TomTat}</p>   </td>
   <td width="237" align="center" class="action">
     <a href="main.php?p=tintuc_chinh&idTin={idTin}"><img title="Chỉnh sửa tin" alt="Chỉnh sửa tin" src="icon_edit.png" /></a> 
     <a href="tintuc_xoa.php?idTin={idTin}"  onclick="return confirm('Bạn có muốn xoá tin này ?');"><img title="Xóa tin" alt="Xóa tin" src="icon_trash.png" /></a> 
      <a href="tintuc_xemchitiet.php?idTin={idTin}"><img title="Xem tin" alt="Xem tin" src="icon_search.png" /></a><img src="AnHien_{AnHien}.gif" width="37" height="35" class="anhien" title="Ẩn hiện tin" value="{idTin}" /><img src="NoiBat_{TinNoiBat}.png" width="37" height="35" class="noibat" title="Tin nổi bật" 	value="{idTin}" /><br />
      &nbsp;</td>
</tr>
<?php 	
$str=ob_get_clean(); 
$str=str_replace("{idTin}", $row_tin['idTin'] , $str);
$str=str_replace("{Ngay}",date('d/m/Y',strtotime($row_tin['Ngay'])) , $str);
$str=str_replace("{TieuDe}", $row_tin['TieuDe'] , $str);
$str=str_replace("{TomTat}", $row_tin['TomTat'] , $str);
$str=str_replace("{SoLanXem}", $row_tin['SoLanXem'] , $str);
$str=str_replace("{AnHien}", $row_tin['AnHien'] , $str);
$str=str_replace("{TinNoiBat}", $row_tin['TinNoiBat'] , $str);
$str=str_replace("{TenTL}", $row_tin['TenTL'] , $str);
$str=str_replace("{Ten}", $row_tin['Ten'] , $str);
echo $str;
?>
<?php } ?>

<!— kết thúc lặp -->
</table>
</form>
</body>
</html>
